import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
import javax.swing.OverlayLayout;


public class cp2 extends JLayeredPane{

	JFrame frame;
	JPanel panel;
	JButton button1;
	JButton button2;
	JButton button3;
	JButton button4;
	private JComponent glass;
    private GridBagLayout layout;
	
	
	public void test() throws Exception{
		
		
		frame = new JFrame("cp");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.add(panel);
		
		button1 = new JButton("test1");
		GridBagConstraints abc = new GridBagConstraints();
		abc.gridx = 0;
		abc.gridy = 0;
		abc.gridheight = 1;
		abc.gridwidth = 1;
		
		button2 = new JButton("teeeeeeeeeeeeeest");
		GridBagConstraints aa = new GridBagConstraints();
		aa.gridx = 1;
		aa.gridy = 0;
		aa.gridheight = 1;
		aa.gridwidth = 1;
		
		button3 = new JButton("test3");
		GridBagConstraints aac = new GridBagConstraints();
		aa.gridx = 0;
		aa.gridy = 1;
		aa.gridheight = 1;
		aa.gridwidth = 1;
		
		button4 = new JButton("haaaaaaaaalo");
		GridBagConstraints a = new GridBagConstraints();
		aa.gridx = 1;
		aa.gridy = 1;
		aa.gridheight = 1;
		aa.gridwidth = 1;
		
		panel.add(button1, abc);
		panel.add(button2, aa);
		panel.add(button3, aac);
		panel.add(button4, a);
		
		frame.pack();
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
	}
	
	
	public cp2() throws Exception{
		setLayout( new OverlayLayout(this));
		layout = new GridBagLayout();
		panel = new JPanel(layout);
		panel.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
		panel.setOpaque(true);
		panel.setBackground(Color.WHITE);
		test();
		
	}
	
	
	
	
	
	
	
	
	
	
	
	
}
